package cate.common.table.item.spice.sheet;

import cate.common.table.ESheet;
import cate.common.table.item.spice.row.SpiceExpRow;
import easy.java.dev.note.NoteClass;

import java.util.ArrayList;
import java.util.List;

@NoteClass(value = "命格升级经验")
public class SpiceExpSheet extends ESheet<SpiceExpRow> {
    @Override
    public String getSheetName() {
        return "星格升级经验";
    }

    /**
     * 查找当前品质和阶数兽魂的最高等级配置
     *
     * @param quality
     * @return
     */
    public SpiceExpRow getMaxLevelRow(int quality) {
        SpiceExpRow maxRow = new SpiceExpRow();
        for (SpiceExpRow row : this.getList()) {
            if (row.quality == quality && row.level >= maxRow.level) {
                maxRow = row;
            }
        }
        return maxRow;
    }

    public List<SpiceExpRow> getRowsByQualityAndLevel(int quality, int level){
        List<SpiceExpRow> rows = new ArrayList<>();
        for(SpiceExpRow row : this.getList()){
            if(row.quality == quality && row.level >= level){
                rows.add(row);
            }
        }
        return rows;
    }

    public long getExpByQualityAndLevel(int quality, int level){
        long exp = 0;
        for(SpiceExpRow row : this.getList()){
            if(row.quality == quality && row.level < level){
                exp += row.expRequired;
            }
        }
        return exp;
    }
}
